Executing AppleScripts with Remote Desktop
AppleScripts can be executed on client computers in two ways. They can be saved and executed as an application, or sent at once using the command line.
To learn more about AppleScript, see AppleScript Help in Help Viewer or go to:
To send and execute an AppleScript:
- Save the AppleScript as an application.
- Open Remote Desktop.
- Select a computer list in the Remote Desktop window.
- Select one or more computers in the selected computer list.
- Use the Copy Items command with the Open Items option selected in the Copy Items dialog.
See Copy Options for more information.
To execute an AppleScript using the Send UNIX Command:
This method uses the osascript command. See the osascript man page for more information.
- Select a computer list in the Remote Desktop window.
- Select one or more computers in the selected computer list.
- Choose Manage > Send UNIX Command.
- Type or paste the AppleScript in the UNIX Command window, like this:
- osascript -e 'First line of script' -e 'Next line of script' [ -e ... ]
Alternatively, you could use a UNIX "read standard input" redirection which looks like:
- osascript <<EndOfMyScript
- ...insert script here...
- EndOfMyScript
For example, a simple script to create a folder and set its label would be entered as:
- osascript <<EndOfMyScript
- tell the application "Finder"
- make new folder
- set the name of the result to "New Folder"
- set the label index of folder "New Folder" to 2
- end tell
- EndOfMyScript
- osascript <<EndOfMyScript
- osascript -e 'First line of script' -e 'Next line of script' [ -e ... ]
- Click Send.
The client computer executes the script.